package com.ticket.web.controller.yanchu;

import com.ticket.common.annotation.Log;
import com.ticket.common.core.controller.BaseController;
import com.ticket.common.core.page.TableDataInfo;
import com.ticket.common.enums.BusinessType;
import com.ticket.common.utils.poi.ExcelUtil;
import com.ticket.system.domain.TYanchuReservedSeats;
import com.ticket.system.domain.TYanchuReservedTicket;
import com.ticket.system.service.ITYanchuReservedTicketService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 预留座与座位关联Controller
 * 
 * @author ruoyi
 * @date 2023-10-18
 */
@RestController
@RequestMapping("/system/ticket")
public class TYanchuReservedTicketController extends BaseController
{
    @Autowired
    private ITYanchuReservedTicketService tYanchuReservedTicketService;

    @ApiOperation("查询预留座与座位关联列表")
    @PreAuthorize("@ss.hasPermi('system:ticket:list')")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "operaId",value = "剧院id",required = true,dataType = "Long",dataTypeClass = Long.class),
            @ApiImplicitParam(name = "sessionId",value = "场次id",required = true,dataType = "Long",dataTypeClass = Long.class),
    })
    @GetMapping("/list")
    public TableDataInfo list(TYanchuReservedTicket tYanchuReservedTicket)
    {
        startPage();
        List<TYanchuReservedSeats> list = tYanchuReservedTicketService.selectReservedTicketList(tYanchuReservedTicket);
        return getDataTable(list);
    }

    /**
     * 导出预留座与座位关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:ticket:export')")
    @Log(title = "预留座与座位关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TYanchuReservedTicket tYanchuReservedTicket)
    {
        List<TYanchuReservedTicket> list = tYanchuReservedTicketService.selectTYanchuReservedTicketList(tYanchuReservedTicket);
        ExcelUtil<TYanchuReservedTicket> util = new ExcelUtil<TYanchuReservedTicket>(TYanchuReservedTicket.class);
        util.exportExcel(response, list, "预留座与座位关联数据");
    }
}
